package com.lynn.springboot_demo.service.serviceImp;

import com.lynn.springboot_demo.dao.UserDao;
import com.lynn.springboot_demo.model.User;
import com.lynn.springboot_demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author cl
 * @Date 2020/5/21 11:21
 */
@Service
public class UserServiceImp implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public void insert(User user) {
        //jpa提供的实体映射，直接存实体对象到数据库
        userDao.save(user);
    }

    @Override
    public void delete(int id) {
        userDao.deleteById(id);
    }

    @Override
    public User findByName(String name) {
        return userDao.findByName(name);
    }

}
